import axios from 'axios'
require('mock/mock.js')

export function request(config) {
  const instance = axios.create({
    baseURL: '',
    timeout: 10,
  })
  instance.interceptors.request.use(res => {
    return res
  }, err => {
    return err
  })

  instance.interceptors.response.use(response => {
    // 根据状态码拦截
    const res = {}
    res.status = response.status
    res.data = response.data
    return res
  }, err => {
    console.log(err);
  })

  return instance(config)
}